<!DOCTYPE HTML>
<html>
<head>
    <title>用户邀请好友管理</title>
    <link rel="stylesheet" href="/stylesheets/style.css">
    <script src="/scripts/jquery.min.js"></script>
    <link rel="stylesheet" href="/scripts/miniui/themes/default/miniui.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/icons.css">
    <link rel="stylesheet" href="/scripts/miniui/themes/bootstrap/skin.css">
    <link rel="stylesheet" href="/editor/common.css">
    <script src="/scripts/miniui/miniui.js"></script>
    <script src="/editor/js/moveBall.js"></script>
</head>
<body  style="padding: 0;width: 100%;height: 100%">
<div id="outImg">
    <img id="imgId" src="" alt="" onclick="smallImg()">
</div>
<div style="padding-bottom:5px;">
    <span>被邀请者昵称：</span><input class="mini-textbox" type="text" id="nickName"/>
    <span>被邀请者电话：</span><input class="mini-textbox" type="number" id="mobilePhoneNumber"/>
    <a class="mini-button" iconCls="icon-search" onclick="search()">查找</a>
</div>
<div style="width:99%;">
    <div class="mini-toolbar" style="border-bottom:0;padding:0px;">
        <table style="width:100%;">
            <tr>
                <td style="width:100%;">
                    <!--<a class="mini-button" iconCls="icon-add" onclick="add()">增加</a>-->
                    <a class="mini-button" iconCls="icon-remove" onclick="remove()">删除</a>
                </td>
            </tr>
        </table>
    </div>
</div>
<div id="datagrid1" class="mini-datagrid" style="width:99%;height: 82%;"
     url="/getdata/getUserInviteFriends" idField="id" allowResize="true"
     sizeList="[20,30,50,100]" pageSize="30"
>
    <div property="columns">
        <div type="checkcolumn" ></div>
        <div field="objectId" width="80" headerAlign="center" allowSort="true" >objectId</div>
        <div field="inviterInviteCode" width="80" headerAlign="center" align="center" allowSort="true" >邀请者邀请码</div>
        <div field="isScoreParent" renderer="statusRenderer" width="80" headerAlign="center" align="center" allowSort="true" >邀请积分状态</div>
        <div field="inviterOId" width="80" headerAlign="center" allowSort="true" >邀请者ID</div>
        <div field="userOId" width="80" headerAlign="center" allowSort="true" >被邀请者ID</div>
        <div field="inviterNickName" width="80" headerAlign="center" allowSort="true" >邀请者昵称</div>
        <div field="userNickName" width="80" headerAlign="center" allowSort="true" >被邀请者昵称</div>
        <div field="mobilePhoneNumber" width="80" headerAlign="center" align="center" allowSort="true" >被邀请者电话</div>
        <div field="createdAt" width="100"  align="center" headerAlign="center" allowSort="true">创建日期</div>
        <div field="updatedAt" width="100"  align="center" headerAlign="center" allowSort="true">更新日期</div>
    </div>
</div>
</body>
<script type="text/javascript">
  var flag = 1;
  mini.parse();
  var grid = mini.get("datagrid1");
  grid.load();
  grid.on("drawcell", function (e) {
    var  value = e.value;
    column = e.column;
  });

  function search() {
    var nickName = mini.get("nickName").getValue();
    var mobilePhoneNumber = mini.get("mobilePhoneNumber").getValue();
    grid.load({
      nickName: nickName,
      mobilePhoneNumber:mobilePhoneNumber,
    });
  }
  $("#nickName,#mobilePhoneNumber").bind("keydown", function (e) {
    if (e.keyCode == 13) {
      search();
    }
  });

  function remove() {
    var row = grid.getSelected();
    if (row) {
      var objectId = row.objectId;
      $.ajax({
        url: "/getdata/userInviteFriendsDel",
        type: 'post',
        data: {
          objectId:objectId
        },
        success: function (result) {
          if (result){
            alert('删除成功')
            grid.reload();
          }else {
            alert('删除失败，请重试！');
            return;
          }
        },
        error: function (error) {
          console.log(error)
        }
      });
    } else {
      alert("请选中一条记录");
    }
  };
  function statusRenderer(e) {
    var value = e.value;
    if (value==true||value==1) {
      return (value, '已领取')
    }else if(value==''){
      return (value, '未领取')
    }
    return (value,'无状态')
  }
</script>
</html>
